# 1.导包
import requests

# 2.创建封装员工管理模块的类
class EmpApi:

    # 3.封装添加员工接口
    def add_emp(self,token,json_dict):
        url = "http://ihrm-test.itheima.net/api/sys/user"
        header_dict = {"Authorization":token}
        return requests.post(url=url,json=json_dict,headers=header_dict)
    # 4.封装查询员工接口
    def query_emp(self,token,emp_id):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        return requests.get(url=url, headers=header_dict)

    # 5.封装修改员工接口
    def update_emp(self,token,json_dict,emp_id):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        return requests.put(url=url,json=json_dict, headers=header_dict)

    # 6.封装删除员工接口
    def del_emp(self,token,emp_id):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        return requests.delete(url=url, headers=header_dict)
